package com.iflytek.ci.qams.dao.impl;

import com.iflytek.ci.qams.dao.IssueBatchDao;
import com.iflytek.ci.qams.dao.IssueDao;
import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 反馈问题批量操作接口实现.
 * </p>
 *
 * @author xzyan
 * @version 1.0 2012-12-10 14:35 PM
 * @since JDK 1.5
 */
@Repository("IssueBatchDao")

public class IssueBatchDaoImpl implements IssueBatchDao {

    /** 注入批处理的SqlSessionTemplate */
    @Qualifier("batchSqlSession")
    @Autowired
    private SqlSessionTemplate batchSqlSession;

    /**
     *  批量更改问题的里程碑标签
     * @param issue_id_milestone_id  两者之间的map对象列表
     */
    @Override
   public  void batch_update_issue_milestone(List <Map<String,Object>>issue_id_milestone_id){

        SqlSession sqlSession = batchSqlSession.getSqlSessionFactory().openSession(ExecutorType.BATCH);
        IssueDao issueDao=sqlSession.getMapper(IssueDao.class);
        for(Map<String,Object> tempMap : issue_id_milestone_id){
            issueDao.update_issue_milestone(tempMap);
        }
        sqlSession.flushStatements();
        sqlSession.commit();
        sqlSession.close();
    }
}
